#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QPushButton"
#include "QDebug"
#include "small_widget.h"
#include "ui_small_widget.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //新增自定义控件
    small_widget *sw1 = new small_widget(this);
    small_widget *sw2 = new small_widget(this);
    sw2->move(100,200);
    //获取按钮连接
    connect(ui->btn_get,&QPushButton::clicked,this,[=](){
        //与主窗口中的widget进行连接
        delete ui->widget;
        delete ui->btn_get;
        qDebug()<< ui->widget->getvalue();
    });
    connect(ui->btn_set,&QPushButton::clicked,this,[=](){
        //与主窗口中的widget进行连接
        ui->widget->setvalue(50);
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

